package com.wzy.spring2.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;

/**
 * @author Weizhengyun
 * @desc
 * @date 2022/12/17 上午10:53
 */
@Component
@Slf4j
public class ThreadInfoPrint implements InitializingBean {

    @Autowired
    @Qualifier("threadPool")
    private ExecutorService executorService;

    @Override
    public void afterPropertiesSet() throws Exception {

//        CompletableFuture.runAsync(() -> {
//            System.out.println("123");
//            while (true) {
//                log.info("thread info = {}", JSON.toJSONString(executorService));
//                try {
//                    TimeUnit.SECONDS.sleep(5);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
//            }
//        }, executorService);
    }
}
